<html>
	<head>
		<title><%= @page_title || "set @page_title!" %></title>
		<%= stylesheet_link_tag "scaffold", "niftyCorners", "main", :media => "all" %>
		<%= javascript_include_tag 'prototype.js', 'effects.js', 'dragdrop.js', 'controls.js', 'niftycube.js', 'fckeditor/fckeditor' %>
		<script type="text/javascript" charset="utf-8">
			window.onload = function() {
				Nifty("div#navigation,div#sub-navigation<%= @rounded_divs %>");
				Nifty("ul#tabs a","small transparent top");
			}
		</script>
	</head>
	<body>
		<div id="wrapper">
			<div id="header"></div>
			<div id="navigation" class="inverse">
				<% if params[:action] != 'reorder' -%>
					<% for page in visible_root_pages -%>
						<%= link_to page.name, :controller => "page", :action => "show", :id => page.slug %> |
					<% end -%>
				<% else -%>
					<%= link_to 'Home', :controller => "page" %> |
				<% end -%>
				<% if user_can?('modify') -%>
					<select onchange="javascript:go(this);" style="font-size:8pt;">
						<option>Actions...</option>
						<option value="add_action" ><%= link_to "Add a page", :controller => "page", :action => "add" %></option>
				<% end -%>
				<% if user_can?('publish') -%>
						<option value="reorder_action"><%= link_to "Reorder pages", :controller => "page", :action => "reorder" %></option>
				<% end -%>
				<% if user_can?('manage') -%>
						<option value="manage_action"><%= link_to "Manage Users", :controller => "users" %></option>
				<% end -%>
				<% if user_can?('modify') -%>
						<option value="sign-out_action"><%= link_to "Sign out", :controller => "logout" %></option>
						<script type="text/javascript" charset="utf-8">
							function go(actions) {
								var action = actions.options[actions.selectedIndex].value;
								if(action == 'add_action')
									window.location = '/page/add';
								else if(action == 'reorder_action')
									window.location = '/page/reorder';
								else if(action == 'manage_action')
									window.location = '/users/';
								else if(action == 'sign-out_action')
									window.location = '/logout/';
							}
						</script>
					</select>
				<% else -%>
					<%= link_to "Sign in", :controller => "login" %>
				<% end -%>
			</div>
			<div id="main">
				<% if @revision != nil && @show_nav -%>
				<div id="sub-navigation" class="inverse">
					<%= display_contextual_navigation_tree(@revision.page) %>
				</div>
				<div id="content">
					<% if flash[:notice] != nil -%><div style="color: green; text-align: center;">&nbsp;<%= flash[:notice] %>&nbsp;</div><% end -%>
					<%= @content_for_layout %>
				</div>
				<% else -%>
					<% if flash[:notice] != nil -%><div style="color: green; text-align: center;">&nbsp;<%= flash[:notice] %>&nbsp;</div><% end -%>
					<%= @content_for_layout %>
				<% end -%>
			</div>
		</div>	
		<div id="footer">Copyright &copy; <%= Time.now.year %></div>
	</body>
</html>